﻿<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        xmlns:local="clr-namespace:WetHatLab.OneNote.TaggingKit.edit"
        xmlns:cui="clr-namespace:WetHatLab.OneNote.TaggingKit.common.ui"
        xmlns:prop="clr-namespace:WetHatLab.OneNote.TaggingKit.Properties"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:TaggingKit="clr-namespace:WetHatLab.OneNote.TaggingKit"
        x:Class="WetHatLab.OneNote.TaggingKit.edit.TagEditor"
        Height="{Binding Source={x:Static prop:Settings.Default},Path=TagEditorWindow_Height,Mode=TwoWay}"
        Width="{Binding Source={x:Static prop:Settings.Default},Path=TagEditorWindow_Width,Mode=TwoWay}"
        Left="{Binding Source={x:Static prop:Settings.Default},Path=TagEditorWindow_Left,Mode=TwoWay}"
        Top="{Binding Source={x:Static prop:Settings.Default},Path=TagEditorWindow_Top,Mode=TwoWay}"
        MinWidth="300"
        MinHeight="430"
        Name="tagEditorWindow"
        mc:Ignorable="d"
        ShowInTaskbar="True"
        d:DataContext="{d:DesignInstance IsDesignTimeCreatable=True, Type={x:Type local:TagEditorDesignerModel}}"
        WindowStyle="ToolWindow"
        Title="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_Window_Title}}"
        Icon="/OneNoteTaggingKit;component/Resources/tag 64x64.png"
        Loaded="Window_Loaded" Closing="editTags_Closing">
    <Window.Resources>
        <ResourceDictionary Source="pack://application:,,,/OneNoteTaggingKit;component/Resources/Styles.xaml"/>
    </Window.Resources>

    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
            <GradientStop Color="Ivory" Offset="0.497"/>
            <GradientStop Color="#FFE1ECF7" Offset="1"/>
        </LinearGradientBrush>
    </Window.Background>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" MinHeight="100"/>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="2*" MinHeight="100" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <StackPanel Grid.Row="0"
                    Orientation="Horizontal"
                    Margin="5,5,0,0"
                    HorizontalAlignment="Left">
            <ComboBox Name="taggingScope"
                HorizontalAlignment="Center"
                SelectedIndex="0"
                ItemsSource="{Binding TaggingScopes}"
                DisplayMemberPath="Label"
                VerticalAlignment="Bottom"
                FontSize="14"
                TextOptions.TextFormattingMode="Display"
                ToolTip="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_ComboBox_Scope_Tooltip}}"
                IsTextSearchEnabled="True" IsEditable="False" Margin="0,0,0,2">
                <ComboBox.Effect>
                    <DropShadowEffect Color="LightBlue"/>
                </ComboBox.Effect>
            </ComboBox>
            <Button Name="addTags"
                Margin="20,0,0,0"
                BorderBrush="LightBlue"
                Background="Honeydew"
                VerticalAlignment="Top"
                Style="{StaticResource controlEffectStyle}"
                ToolTip="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_AddTags_Button_Tooltip}}"
                Click="AddTagsToPageButton_Click">
                <Image Source="/OneNoteTaggingKit;component/Resources/Add Tag 26.png"  Width="26" Height="26" RenderTransformOrigin="0.5,0.5" />
            </Button>
            <Button
                Margin="10,0,0,0"
                BorderBrush="LightBlue"
                Background="Ivory"
                VerticalAlignment="Top"
                Style="{StaticResource controlEffectStyle}"
                ToolTip="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_SetTags_Button_Tooltip}}"
                Click="SetPageTagsButton_Click">
                <Image Source="/OneNoteTaggingKit;component/Resources/Set Tag 26.png"  Width="26" Height="26" />
            </Button>
            <Button 
                Margin="10,0,00,0"
                Style="{StaticResource controlEffectStyle}"
                Background="#FFFFEAE8"
                VerticalAlignment="Top"
                ToolTip="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_RemoveTags_Button_Tooltip}}"
                Click="RemoveTagsFromPageButton_Click">
                <Image Source="/OneNoteTaggingKit;component/Resources/Remove Tag 26.png" Width="26" Height="26"/>
            </Button>
            <Popup Name="pagesTaggedPopup"
               PlacementTarget="{Binding ElementName=addTags}"
               StaysOpen="False"
               AllowsTransparency="True"
               MouseDown="handlePopupPointerAction"
               StylusDown="handlePopupPointerAction"
               TouchDown="handlePopupPointerAction"
               VerticalOffset="20">
                <Border BorderThickness="2"
                        BorderBrush="DarkSlateBlue"
                        Background="LightYellow"
                        CornerRadius="10">
                    <Border.Effect>
                        <DropShadowEffect Color="LightGray"/>
                    </Border.Effect>
                    <TextBlock Name="pagesTaggedText"
                               MaxWidth="200"
                               Margin="5,5,5,5"
                               TextWrapping="Wrap"
                               TextTrimming="CharacterEllipsis"
                               Text="x pages tagged"
                               FontSize="16" Background="Transparent"/>
                </Border>
            </Popup>
            <Popup Name="progressPopup"
               PlacementTarget="{Binding ElementName=addTags}"
               StaysOpen="False"
               MouseDown="handlePopupPointerAction"
               StylusDown="handlePopupPointerAction"
               TouchDown="handlePopupPointerAction"
               AllowsTransparency="True"
               VerticalOffset="20">
                <Border BorderThickness="2"
                        Background="LightYellow"
                        BorderBrush="DarkSlateBlue"
                        CornerRadius="10">
                    <Border.Effect>
                        <DropShadowEffect Color="LightGray"/>
                    </Border.Effect>
                    <TextBlock MaxWidth="200"
                               Margin="5,5,5,5"
                               TextWrapping="Wrap"
                               TextTrimming="CharacterEllipsis"
                               Text="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_Popup_TaggingInProgress}}"
                               FontSize="16" Background="Transparent"/>
                </Border>
            </Popup>
        </StackPanel>
        <GroupBox Name="selectedTags"  Grid.Row="1"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch"
                  Margin="5,0,5,0"
                  Background="Transparent"
                  ToolTip="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_Tags_GroupBox_ToolTip}}">
            <GroupBox.Header>
                <TextBlock>
                  <Run Text="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_Tags_GroupBox_Title}}"/>
                </TextBlock>
            </GroupBox.Header>
            <local:SimpleTagsPanel Tags="{Binding PageTags}"
                                   Background="Transparent"
                                   VerticalAlignment="Stretch"
                                   Click="RemovePageTagButton_Click"/>
        </GroupBox>
        <Button Grid.Row="1"
                Width="26"
                Background="Transparent"
                VerticalAlignment="Top"
                HorizontalAlignment="Right"
                BorderThickness="0" BorderBrush="LightBlue"
                Margin="0,0,25,0"
                ToolTip="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_ClearTags_Button_Tooltip}}"
                Click="ClearTagsButton_Click" >
            <Image Source="/OneNoteTaggingKit;component/Resources/clear selection.png"/>
        </Button>

        <GridSplitter Grid.Row="2" 
                      ResizeBehavior="PreviousAndNext"
                      ResizeDirection="Rows"
                      VerticalAlignment="Top"
                      HorizontalAlignment="Stretch"
                      Height="5" >
            <GridSplitter.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FFE2EDF7" Offset="0.67"/>
                </LinearGradientBrush>
            </GridSplitter.Background>
        </GridSplitter>
        <cui:TagInputBox Grid.Row="2"
                         x:Name="tagInput"
                         Margin="5,10,5,0"
                         ToolTip="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_Tag_TextBox_Tooltip}}"
                         ContextTagsSource="{Binding ContextTagCollection}"
                         TagInput="TagInputBox_Input"/>
        <cui:HighlightedTagsPanel Grid.Row="3"
                                  x:Name="suggestedTags"
                                  Margin="5,0,5,0"
                                  Background="Transparent"
                                  TagSource="{Binding TagSuggestions,Mode=OneWay}"
                                  Header="{Binding Mode=OneTime, Source={x:Static prop:Resources.TagEditor_Suggestions_GroupBox_Title}}">
            <cui:HighlightedTagsPanel.TagTemplate>
                <DataTemplate>
                    <local:HitHighlightedTagButton Margin="0,5,5,0" Click="OnSuggestedTagClick"/>
                </DataTemplate>
            </cui:HighlightedTagsPanel.TagTemplate>
        </cui:HighlightedTagsPanel>
        <ProgressBar Name="pBar" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"/>
    </Grid>
</Window>
